package com.qfedu.controller;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.qfedu.pojo.SysOrder;
import com.qfedu.pojo.SysUser;
import com.qfedu.service.SysOrderService;
import com.qfedu.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.awt.image.BandedSampleModel;
import java.util.Map;

@RequestMapping("/order2")
@RestController
public class SysOrderController {
    @Autowired
    SysOrderService orderService;
    @RequestMapping("/add")
    public BaseResult add(Integer cid, Integer getid, Integer backid, Double oprice, HttpServletRequest request){
        SysOrder sysOrder=new SysOrder(null,cid,((SysUser)request.getSession().getAttribute("user")).getId(),getid,backid,oprice,"已预定");
        System.out.println(sysOrder);
        return orderService.add(sysOrder);
    }
    @RequestMapping("/all")
    public BaseResult all(Integer page,Integer limit,HttpServletRequest request){
        return orderService.all(page,limit,request);
    }
    @RequestMapping("/del2")
    public BaseResult del(@RequestBody Map map){
        int id = Integer.parseInt(map.get("id").toString());
        System.out.println(id);
        return orderService.del(id);

    }
}
